﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using HFBizDBLib;
using DevExpress.XtraGrid.Views.Base;

namespace HFBizSystemLib
{
    public partial class xfWarehouse : HFBizFormLib.xfBase
    {
        private DataClassDataContext tdc;
        private ColumnView view;

        public xfWarehouse()
        {
            InitializeComponent();
            view = gcWarehouse.MainView as ColumnView;
        }

        private void dbBinding()
        {
            var twh = from p in tdc.Warehouse
                      select p;
            gcWarehouse.DataSource = twh;

            var te = from p in tdc.Employee
                     select p;
            rilueEmployee.DataSource = te;
        }

        private void xfWarehouse_Load(object sender, EventArgs e)
        {
            tdc = new DataClassDataContext();
            dbBinding();
        }

        private void sbCommit_Click(object sender, EventArgs e)
        {
            tdc.SubmitChanges();
            dbBinding();
        }

        private void sbDelete_Click(object sender, EventArgs e)
        {
            view.DeleteRow(view.FocusedRowHandle);
            tdc.SubmitChanges();
            dbBinding();
        }

        private void sbExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
